In [ ]:
import numpy as np
from menpo.shape import PointCloud
from menpo.transform import HomogeneousTransform
If you know the form of a basic homogeneous transform (like here a mirror along y=x) it's trivial to build a HomogeneousTransform
to use this operation in Menpo
In [ ]:
# mirror along y=x
xy_yx = HomogeneousTransform(np.array([[0, 1, 0],
[1, 0, 0],
[0, 0, 1]]))
In [ ]:
pc = PointCloud(np.random.random([12, 2]))
print pc
In [ ]:
%matplotlib inline
pc.view()
Applying this Transform to a PointCloud
has the desired effect
In [ ]:
pc_flipped = xy_yx.apply(pc)
In [ ]:
pc_flipped.view()
Homogeneous transforms support native composition
In [ ]:
no_op = xy_yx.compose_before(xy_yx)
print no_op.h_matrix
In [ ]:
no_op = xy_yx.compose_after(xy_yx)
print no_op.h_matrix
In [ ]:
xy_yx.compose_before_inplace(xy_yx)
print xy_yx.h_matrix